import { createRouter, createWebHistory } from 'vue-router'
import courseRoutes from './routes/course_routes'
import desktopRoutes from './routes/desktop_routes'
import managementRoutes from './routes/management_routes'
import CultivationRoutes from './routes/cultivation_routes'
import studentRoutes from './routes/student_routes'
const routes = [
  {
    path: '/',
    component: () => import('@/components/Navi.vue'),
    redirect: '/homepage',
    meta: { requiresAuth: true },
    children: [
      {
        path: '/homepage',
        name: 'homepage',
        component: () => import('@/views/MainPage.vue')
      },
      ...courseRoutes,
      ...desktopRoutes,
      ...managementRoutes,
      ...CultivationRoutes,
      ...studentRoutes
    ]
  },
  {
    path: '/blog',
    name: 'blog',
    children: [
      {
        path: '',
        name: 'blog-main',
        component: () => import('@/views/Blog/Blog.vue'),
        props: true
      },
      {
        path: 'write',
        name: 'write',
        component: () => import('@/views/Blog/WriteBlog.vue')
      },
      {
        path: 'detail',
        name: 'blog-detail',
        component: () => import('@/views/Blog/BlogDetail.vue'),
        props: (route: any) => ({ id: route.query.id })
      }
    ]
  },
  {
    path: '/login',
    name: 'login',
    component: () => import('@/views/Login/Login.vue'),
    meta: { requiresAuth: false }
  },
  {
    path: '/forgot-password',
    name: 'forgot-password',
    component: () => import('@/views/Login/ForgotPassword.vue'),
    meta: { requiresAuth: false }
  }
]
const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes
})
export default router
